package gdx_tyrian.screen;

import gdx_tyrian.Tyrian;

import com.badlogic.gdx.Gdx;
import com.badlogic.gdx.Screen;
import com.badlogic.gdx.graphics.GL20;
import com.badlogic.gdx.graphics.g2d.BitmapFont;
import com.badlogic.gdx.graphics.g2d.SpriteBatch;
import com.badlogic.gdx.scenes.scene2d.Stage;

public abstract class AbstractScreen implements Screen {
	
	protected final Tyrian game;
	protected final BitmapFont font;
	protected final SpriteBatch batch;
	protected final Stage stage;

	public AbstractScreen(Tyrian game) {
		this.game = game;
		this.font = new BitmapFont();
		this.batch = new SpriteBatch();
		this.stage = new Stage();
	}

	@Override
	public void show() {
	}

	@Override
	public void resize(int width, int height) {
		Gdx.app.log( Tyrian.LOG, "Resizing screen to: " + width + " x " + height );

        // resize the stage
        stage.setViewport( width, height, true );
	}

	@Override
	public void render(float delta) {
		// the following code clears the screen with the given RGB color (black)
		Gdx.gl.glClearColor(0f, 0f, 0f, 1f);
		Gdx.gl.glClear(GL20.GL_COLOR_BUFFER_BIT);
		
		stage.act(delta);
		stage.draw();
	}

	@Override
	public void hide() {
	}

	@Override
	public void pause() {
	}

	@Override
	public void resume() {
	}

	@Override
	public void dispose() {
		font.dispose();
		batch.dispose();
		stage.dispose();
	}
}
